package it.prucina.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class webview extends Activity {
	WebView mwebview;
	
	private class webviewclient extends WebViewClient {
	    @Override
	    public boolean shouldOverrideUrlLoading(WebView view, String url) {
	        view.loadUrl(url);
	        return true;
	    }
	}
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.webview);
		
		mwebview = (WebView) this.findViewById(R.id.webview);
		mwebview.getSettings().setJavaScriptEnabled(true);
		mwebview.setWebViewClient(new webviewclient());
		mwebview.loadUrl("http://www.google.it");
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent event) {
	    if ((keyCode == KeyEvent.KEYCODE_BACK) && mwebview.canGoBack()) {
	        mwebview.goBack();
	        return true;
	    }
	    return super.onKeyDown(keyCode, event);
	}
}
